package com.itmayiedu.start;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.client.RestTemplate;

/**
 * *******************************************
 *
 * @description:
 * @author: by jgl
 * @date: 2018/1/30 0030 下午 10:19
 * @version:1.0 *******************************************
 */
@ComponentScan(basePackages = {"com.itmayiedu"})
@SpringBootApplication
@EnableEurekaClient
@EnableHystrix
//@EnableDiscoveryClient //如果选用的注册中心是eureka，那么就推荐@EnableEurekaClient，如果是其他的注册中心，那么推荐使用@EnableDiscoveryClient。
public class HystrixAppClient {
    
    public static void main(String[] args){
        SpringApplication.run(HystrixAppClient.class,args);
    }

    /**
     * 使用restTemplate模板，支持负载均衡
     * @return
     */
    @Bean
    @LoadBalanced
    RestTemplate restTemplate(){
        return new RestTemplate();
    }
}
